package org.mt4jx.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.StringTokenizer;

import org.mt4j.util.MTColor;
import org.mt4j.util.logging.ILogger;
import org.mt4j.util.logging.MTLoggerFactory;

public class MTColors {

    private static final ILogger LOG = MTLoggerFactory.getLogger(MTColors.class.getName());

    static {
        LOG.setLevel(ILogger.DEBUG);
    }

    private static Hashtable<String, MTColor> colors = new Hashtable<String, MTColor>();

    public static final MTColor ALICEBLUE = new MTColor(240, 248, 255);
    {
        colors.put("ALICEBLUE", ALICEBLUE);
    }

    public static final MTColor ANTIQUEWHITE = new MTColor(250, 235, 215);
    {
        colors.put("ANTIQUEWHITE", ANTIQUEWHITE);
    }

    public static final MTColor AQUA = new MTColor(0, 255, 255);
    {
        colors.put("AQUA", AQUA);
    }

    public static final MTColor AQUAMARINE = new MTColor(127, 255, 212);
    {
        colors.put("AQUAMARINE", AQUAMARINE);
    }

    public static final MTColor AZURE = new MTColor(240, 255, 255);
    {
        colors.put("AZURE", AZURE);
    }

    public static final MTColor BEIGE = new MTColor(245, 245, 220);
    {
        colors.put("BEIGE", BEIGE);
    }

    public static final MTColor BISQUE = new MTColor(255, 228, 196);
    {
        colors.put("BISQUE", BISQUE);
    }

    public static final MTColor BLACK = new MTColor(0, 0, 0);
    {
        colors.put("BLACK", BLACK);
    }

    public static final MTColor BLANCHEDALMOND = new MTColor(255, 235, 205);
    {
        colors.put("BLANCHEDALMOND", BLANCHEDALMOND);
    }

    public static final MTColor BLUE = new MTColor(0, 0, 255);
    {
        colors.put("BLUE", BLUE);
    }

    public static final MTColor BLUEVIOLET = new MTColor(138, 43, 226);
    {
        colors.put("BLUEVIOLET", BLUEVIOLET);
    }

    public static final MTColor BROWN = new MTColor(165, 42, 42);
    {
        colors.put("BROWN", BROWN);
    }

    public static final MTColor BURLYWOOD = new MTColor(222, 184, 135);
    {
        colors.put("BURLYWOOD", BURLYWOOD);
    }

    public static final MTColor CADETBLUE = new MTColor(95, 158, 160);
    {
        colors.put("CADETBLUE", CADETBLUE);
    }

    public static final MTColor CHARTREUSE = new MTColor(127, 255, 0);
    {
        colors.put("CHARTREUSE", CHARTREUSE);
    }

    public static final MTColor CHOCOLATE = new MTColor(210, 105, 30);
    {
        colors.put("CHOCOLATE", CHOCOLATE);
    }

    public static final MTColor CORAL = new MTColor(255, 127, 80);
    {
        colors.put("CORAL", CORAL);
    }

    public static final MTColor CORNFLOWERBLUE = new MTColor(100, 149, 237);
    {
        colors.put("CORNFLOWERBLUE", CORNFLOWERBLUE);
    }

    public static final MTColor CORNSILK = new MTColor(255, 248, 220);
    {
        colors.put("CORNSILK", CORNSILK);
    }

    public static final MTColor CRIMSON = new MTColor(220, 20, 60);
    {
        colors.put("CRIMSON", CRIMSON);
    }

    public static final MTColor CYAN = new MTColor(0, 255, 255);
    {
        colors.put("CYAN", CYAN);
    }

    public static final MTColor DARKBLUE = new MTColor(0, 0, 139);
    {
        colors.put("DARKBLUE", DARKBLUE);
    }

    public static final MTColor DARKCYAN = new MTColor(0, 139, 139);
    {
        colors.put("DARKCYAN", DARKCYAN);
    }

    public static final MTColor DARKGOLDENROD = new MTColor(184, 134, 11);
    {
        colors.put("DARKGOLDENROD", DARKGOLDENROD);
    }

    public static final MTColor DARKGRAY = new MTColor(169, 169, 169);
    {
        colors.put("DARKGRAY", DARKGRAY);
    }

    public static final MTColor DARKGREY = new MTColor(169, 169, 169);
    {
        colors.put("DARKGREY", DARKGREY);
    }

    public static final MTColor DARKGREEN = new MTColor(0, 100, 0);
    {
        colors.put("DARKGREEN", DARKGREEN);
    }

    public static final MTColor DARKKHAKI = new MTColor(189, 183, 107);
    {
        colors.put("DARKKHAKI", DARKKHAKI);
    }

    public static final MTColor DARKMAGENTA = new MTColor(139, 0, 139);
    {
        colors.put("DARKMAGENTA", DARKMAGENTA);
    }

    public static final MTColor DARKOLIVEGREEN = new MTColor(85, 107, 47);
    {
        colors.put("DARKOLIVEGREEN", DARKOLIVEGREEN);
    }

    public static final MTColor DARKORANGE = new MTColor(255, 140, 0);
    {
        colors.put("DARKORANGE", DARKORANGE);
    }

    public static final MTColor DARKORCHID = new MTColor(153, 50, 204);
    {
        colors.put("DARKORCHID", DARKORCHID);
    }

    public static final MTColor DARKRED = new MTColor(139, 0, 0);
    {
        colors.put("DARKRED", DARKRED);
    }

    public static final MTColor DARKSALMON = new MTColor(233, 150, 122);
    {
        colors.put("DARKSALMON", DARKSALMON);
    }

    public static final MTColor DARKSEAGREEN = new MTColor(143, 188, 143);
    {
        colors.put("DARKSEAGREEN", DARKSEAGREEN);
    }

    public static final MTColor DARKSLATEBLUE = new MTColor(72, 61, 139);
    {
        colors.put("DARKSLATEBLUE", DARKSLATEBLUE);
    }

    public static final MTColor DARKSLATEGRAY = new MTColor(47, 79, 79);
    {
        colors.put("DARKSLATEGRAY", DARKSLATEGRAY);
    }

    public static final MTColor DARKSLATEGREY = new MTColor(47, 79, 79);
    {
        colors.put("DARKSLATEGREY", DARKSLATEGREY);
    }

    public static final MTColor DARKTURQUOISE = new MTColor(0, 206, 209);
    {
        colors.put("DARKTURQUOISE", DARKTURQUOISE);
    }

    public static final MTColor DARKVIOLET = new MTColor(148, 0, 211);
    {
        colors.put("DARKVIOLET", DARKVIOLET);
    }

    public static final MTColor DEEPPINK = new MTColor(255, 20, 147);
    {
        colors.put("DEEPPINK", DEEPPINK);
    }

    public static final MTColor DEEPSKYBLUE = new MTColor(0, 191, 255);
    {
        colors.put("DEEPSKYBLUE", DEEPSKYBLUE);
    }

    public static final MTColor DIMGRAY = new MTColor(105, 105, 105);
    {
        colors.put("DIMGRAY", DIMGRAY);
    }

    public static final MTColor DIMGREY = new MTColor(105, 105, 105);
    {
        colors.put("DIMGREY", DIMGREY);
    }

    public static final MTColor DODGERBLUE = new MTColor(30, 144, 255);
    {
        colors.put("DODGERBLUE", DODGERBLUE);
    }

    public static final MTColor FIREBRICK = new MTColor(178, 34, 34);
    {
        colors.put("FIREBRICK", FIREBRICK);
    }

    public static final MTColor FLORALWHITE = new MTColor(255, 250, 240);
    {
        colors.put("FLORALWHITE", FLORALWHITE);
    }

    public static final MTColor FORESTGREEN = new MTColor(34, 139, 34);
    {
        colors.put("FORESTGREEN", FORESTGREEN);
    }

    public static final MTColor FUCHSIA = new MTColor(255, 0, 255);
    {
        colors.put("FUCHSIA", FUCHSIA);
    }

    public static final MTColor GAINSBORO = new MTColor(220, 220, 220);
    {
        colors.put("GAINSBORO", GAINSBORO);
    }

    public static final MTColor GHOSTWHITE = new MTColor(248, 248, 255);
    {
        colors.put("GHOSTWHITE", GHOSTWHITE);
    }

    public static final MTColor GOLD = new MTColor(255, 215, 0);
    {
        colors.put("GOLD", GOLD);
    }

    public static final MTColor GOLDENROD = new MTColor(218, 165, 32);
    {
        colors.put("GOLDENROD", GOLDENROD);
    }

    public static final MTColor GRAY = new MTColor(128, 128, 128);
    {
        colors.put("GRAY", GRAY);
    }

    public static final MTColor GREY = new MTColor(128, 128, 128);
    {
        colors.put("GREY", GREY);
    }

    public static final MTColor GREEN = new MTColor(0, 128, 0);
    {
        colors.put("GREEN", GREEN);
    }

    public static final MTColor GREENYELLOW = new MTColor(173, 255, 47);
    {
        colors.put("GREENYELLOW", GREENYELLOW);
    }

    public static final MTColor HONEYDEW = new MTColor(240, 255, 240);
    {
        colors.put("HONEYDEW", HONEYDEW);
    }

    public static final MTColor HOTPINK = new MTColor(255, 105, 180);
    {
        colors.put("HOTPINK", HOTPINK);
    }

    public static final MTColor INDIANRED = new MTColor(205, 92, 92);
    {
        colors.put("INDIANRED", INDIANRED);
    }

    public static final MTColor INDIGO = new MTColor(75, 0, 130);
    {
        colors.put("INDIGO", INDIGO);
    }

    public static final MTColor IVORY = new MTColor(255, 255, 240);
    {
        colors.put("IVORY", IVORY);
    }

    public static final MTColor KHAKI = new MTColor(240, 230, 140);
    {
        colors.put("KHAKI", KHAKI);
    }

    public static final MTColor LAVENDER = new MTColor(230, 230, 250);
    {
        colors.put("LAVENDER", LAVENDER);
    }

    public static final MTColor LAVENDERBLUSH = new MTColor(255, 240, 245);
    {
        colors.put("LAVENDERBLUSH", LAVENDERBLUSH);
    }

    public static final MTColor LAWNGREEN = new MTColor(124, 252, 0);
    {
        colors.put("LAWNGREEN", LAWNGREEN);
    }

    public static final MTColor LEMONCHIFFON = new MTColor(255, 250, 205);
    {
        colors.put("LEMONCHIFFON", LEMONCHIFFON);
    }

    public static final MTColor LIGHTBLUE = new MTColor(173, 216, 230);
    {
        colors.put("LIGHTBLUE", LIGHTBLUE);
    }

    public static final MTColor LIGHTCORAL = new MTColor(240, 128, 128);
    {
        colors.put("LIGHTCORAL", LIGHTCORAL);
    }

    public static final MTColor LIGHTCYAN = new MTColor(224, 255, 255);
    {
        colors.put("LIGHTCYAN", LIGHTCYAN);
    }

    public static final MTColor LIGHTGOLDENRODYELLOW = new MTColor(250, 250, 210);
    {
        colors.put("LIGHTGOLDENRODYELLOW", LIGHTGOLDENRODYELLOW);
    }

    public static final MTColor LIGHTGRAY = new MTColor(211, 211, 211);
    {
        colors.put("LIGHTGRAY", LIGHTGRAY);
    }

    public static final MTColor LIGHTGREY = new MTColor(211, 211, 211);
    {
        colors.put("LIGHTGREY", LIGHTGREY);
    }

    public static final MTColor LIGHTGREEN = new MTColor(144, 238, 144);
    {
        colors.put("LIGHTGREEN", LIGHTGREEN);
    }

    public static final MTColor LIGHTPINK = new MTColor(255, 182, 193);
    {
        colors.put("LIGHTPINK", LIGHTPINK);
    }

    public static final MTColor LIGHTSALMON = new MTColor(255, 160, 122);
    {
        colors.put("LIGHTSALMON", LIGHTSALMON);
    }

    public static final MTColor LIGHTSEAGREEN = new MTColor(32, 178, 170);
    {
        colors.put("LIGHTSEAGREEN", LIGHTSEAGREEN);
    }

    public static final MTColor LIGHTSKYBLUE = new MTColor(135, 206, 250);
    {
        colors.put("LIGHTSKYBLUE", LIGHTSKYBLUE);
    }

    public static final MTColor LIGHTSLATEGRAY = new MTColor(119, 136, 153);
    {
        colors.put("LIGHTSLATEGRAY", LIGHTSLATEGRAY);
    }

    public static final MTColor LIGHTSLATEGREY = new MTColor(119, 136, 153);
    {
        colors.put("LIGHTSLATEGREY", LIGHTSLATEGREY);
    }

    public static final MTColor LIGHTSTEELBLUE = new MTColor(176, 196, 222);
    {
        colors.put("LIGHTSTEELBLUE", LIGHTSTEELBLUE);
    }

    public static final MTColor LIGHTYELLOW = new MTColor(255, 255, 224);
    {
        colors.put("LIGHTYELLOW", LIGHTYELLOW);
    }

    public static final MTColor LIME = new MTColor(0, 255, 0);
    {
        colors.put("LIME", LIME);
    }

    public static final MTColor LIMEGREEN = new MTColor(50, 205, 50);
    {
        colors.put("LIMEGREEN", LIMEGREEN);
    }

    public static final MTColor LINEN = new MTColor(250, 240, 230);
    {
        colors.put("LINEN", LINEN);
    }

    public static final MTColor MAGENTA = new MTColor(255, 0, 255);
    {
        colors.put("MAGENTA", MAGENTA);
    }

    public static final MTColor MAROON = new MTColor(128, 0, 0);
    {
        colors.put("MAROON", MAROON);
    }

    public static final MTColor MEDIUMAQUAMARINE = new MTColor(102, 205, 170);
    {
        colors.put("MEDIUMAQUAMARINE", MEDIUMAQUAMARINE);
    }

    public static final MTColor MEDIUMBLUE = new MTColor(0, 0, 205);
    {
        colors.put("MEDIUMBLUE", MEDIUMBLUE);
    }

    public static final MTColor MEDIUMORCHID = new MTColor(186, 85, 211);
    {
        colors.put("MEDIUMORCHID", MEDIUMORCHID);
    }

    public static final MTColor MEDIUMPURPLE = new MTColor(147, 112, 216);
    {
        colors.put("MEDIUMPURPLE", MEDIUMPURPLE);
    }

    public static final MTColor MEDIUMSEAGREEN = new MTColor(60, 179, 113);
    {
        colors.put("MEDIUMSEAGREEN", MEDIUMSEAGREEN);
    }

    public static final MTColor MEDIUMSLATEBLUE = new MTColor(123, 104, 238);
    {
        colors.put("MEDIUMSLATEBLUE", MEDIUMSLATEBLUE);
    }

    public static final MTColor MEDIUMSPRINGGREEN = new MTColor(0, 250, 154);
    {
        colors.put("MEDIUMSPRINGGREEN", MEDIUMSPRINGGREEN);
    }

    public static final MTColor MEDIUMTURQUOISE = new MTColor(72, 209, 204);
    {
        colors.put("MEDIUMTURQUOISE", MEDIUMTURQUOISE);
    }

    public static final MTColor MEDIUMVIOLETRED = new MTColor(199, 21, 133);
    {
        colors.put("MEDIUMVIOLETRED", MEDIUMVIOLETRED);
    }

    public static final MTColor MIDNIGHTBLUE = new MTColor(25, 25, 112);
    {
        colors.put("MIDNIGHTBLUE", MIDNIGHTBLUE);
    }

    public static final MTColor MINTCREAM = new MTColor(245, 255, 250);
    {
        colors.put("MINTCREAM", MINTCREAM);
    }

    public static final MTColor MISTYROSE = new MTColor(255, 228, 225);
    {
        colors.put("MISTYROSE", MISTYROSE);
    }

    public static final MTColor MOCCASIN = new MTColor(255, 228, 181);
    {
        colors.put("MOCCASIN", MOCCASIN);
    }

    public static final MTColor NAVAJOWHITE = new MTColor(255, 222, 173);
    {
        colors.put("NAVAJOWHITE", NAVAJOWHITE);
    }

    public static final MTColor NAVY = new MTColor(0, 0, 128);
    {
        colors.put("NAVY", NAVY);
    }

    public static final MTColor OLDLACE = new MTColor(253, 245, 230);
    {
        colors.put("OLDLACE", OLDLACE);
    }

    public static final MTColor OLIVE = new MTColor(128, 128, 0);
    {
        colors.put("OLIVE", OLIVE);
    }

    public static final MTColor OLIVEDRAB = new MTColor(107, 142, 35);
    {
        colors.put("OLIVEDRAB", OLIVEDRAB);
    }

    public static final MTColor ORANGE = new MTColor(255, 165, 0);
    {
        colors.put("ORANGE", ORANGE);
    }

    public static final MTColor ORANGERED = new MTColor(255, 69, 0);
    {
        colors.put("ORANGERED", ORANGERED);
    }

    public static final MTColor ORCHID = new MTColor(218, 112, 214);
    {
        colors.put("ORCHID", ORCHID);
    }

    public static final MTColor PALEGOLDENROD = new MTColor(238, 232, 170);
    {
        colors.put("PALEGOLDENROD", PALEGOLDENROD);
    }

    public static final MTColor PALEGREEN = new MTColor(152, 251, 152);
    {
        colors.put("PALEGREEN", PALEGREEN);
    }

    public static final MTColor PALETURQUOISE = new MTColor(175, 238, 238);
    {
        colors.put("PALETURQUOISE", PALETURQUOISE);
    }

    public static final MTColor PALEVIOLETRED = new MTColor(216, 112, 147);
    {
        colors.put("PALEVIOLETRED", PALEVIOLETRED);
    }

    public static final MTColor PAPAYAWHIP = new MTColor(255, 239, 213);
    {
        colors.put("PAPAYAWHIP", PAPAYAWHIP);
    }

    public static final MTColor PEACHPUFF = new MTColor(255, 218, 185);
    {
        colors.put("PEACHPUFF", PEACHPUFF);
    }

    public static final MTColor PERU = new MTColor(205, 133, 63);
    {
        colors.put("PERU", PERU);
    }

    public static final MTColor PINK = new MTColor(255, 192, 203);
    {
        colors.put("PINK", PINK);
    }

    public static final MTColor PLUM = new MTColor(221, 160, 221);
    {
        colors.put("PLUM", PLUM);
    }

    public static final MTColor POWDERBLUE = new MTColor(176, 224, 230);
    {
        colors.put("POWDERBLUE", POWDERBLUE);
    }

    public static final MTColor PURPLE = new MTColor(128, 0, 128);
    {
        colors.put("PURPLE", PURPLE);
    }

    public static final MTColor RED = new MTColor(255, 0, 0);
    {
        colors.put("RED", RED);
    }

    public static final MTColor ROSYBROWN = new MTColor(188, 143, 143);
    {
        colors.put("ROSYBROWN", ROSYBROWN);
    }

    public static final MTColor ROYALBLUE = new MTColor(65, 105, 225);
    {
        colors.put("ROYALBLUE", ROYALBLUE);
    }

    public static final MTColor SADDLEBROWN = new MTColor(139, 69, 19);
    {
        colors.put("SADDLEBROWN", SADDLEBROWN);
    }

    public static final MTColor SALMON = new MTColor(250, 128, 114);
    {
        colors.put("SALMON", SALMON);
    }

    public static final MTColor SANDYBROWN = new MTColor(244, 164, 96);
    {
        colors.put("SANDYBROWN", SANDYBROWN);
    }

    public static final MTColor SEAGREEN = new MTColor(46, 139, 87);
    {
        colors.put("SEAGREEN", SEAGREEN);
    }

    public static final MTColor SEASHELL = new MTColor(255, 245, 238);
    {
        colors.put("SEASHELL", SEASHELL);
    }

    public static final MTColor SIENNA = new MTColor(160, 82, 45);
    {
        colors.put("SIENNA", SIENNA);
    }

    public static final MTColor SILVER = new MTColor(192, 192, 192);
    {
        colors.put("SILVER", SILVER);
    }

    public static final MTColor SKYBLUE = new MTColor(135, 206, 235);
    {
        colors.put("SKYBLUE", SKYBLUE);
    }

    public static final MTColor SLATEBLUE = new MTColor(106, 90, 205);
    {
        colors.put("SLATEBLUE", SLATEBLUE);
    }

    public static final MTColor SLATEGRAY = new MTColor(112, 128, 144);
    {
        colors.put("SLATEGRAY", SLATEGRAY);
    }

    public static final MTColor SLATEGREY = new MTColor(112, 128, 144);
    {
        colors.put("SLATEGREY", SLATEGREY);
    }

    public static final MTColor SNOW = new MTColor(255, 250, 250);
    {
        colors.put("SNOW", SNOW);
    }

    public static final MTColor SPRINGGREEN = new MTColor(0, 255, 127);
    {
        colors.put("SPRINGGREEN", SPRINGGREEN);
    }

    public static final MTColor STEELBLUE = new MTColor(70, 130, 180);
    {
        colors.put("STEELBLUE", STEELBLUE);
    }

    public static final MTColor TAN = new MTColor(210, 180, 140);
    {
        colors.put("TAN", TAN);
    }

    public static final MTColor TEAL = new MTColor(0, 128, 128);
    {
        colors.put("TEAL", TEAL);
    }

    public static final MTColor THISTLE = new MTColor(216, 191, 216);
    {
        colors.put("THISTLE", THISTLE);
    }

    public static final MTColor TOMATO = new MTColor(255, 99, 71);
    {
        colors.put("TOMATO", TOMATO);
    }

    public static final MTColor TURQUOISE = new MTColor(64, 224, 208);
    {
        colors.put("TURQUOISE", TURQUOISE);
    }

    public static final MTColor VIOLET = new MTColor(238, 130, 238);
    {
        colors.put("VIOLET", VIOLET);
    }

    public static final MTColor WHEAT = new MTColor(245, 222, 179);
    {
        colors.put("WHEAT", WHEAT);
    }

    public static final MTColor WHITE = new MTColor(255, 255, 255);
    {
        colors.put("WHITE", WHITE);
    }

    public static final MTColor WHITESMOKE = new MTColor(245, 245, 245);
    {
        colors.put("WHITESMOKE", WHITESMOKE);
    }

    public static final MTColor YELLOW = new MTColor(255, 255, 0);
    {
        colors.put("YELLOW", YELLOW);
    }

    public static final MTColor YELLOWGREEN = new MTColor(154, 205, 50);
    {
        colors.put("YELLOWGREEN", YELLOWGREEN);
    }

    public static void main(String[] args) {
        try {
            final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("D:/colors.csv"))));
            String line = null;
            while ((line = br.readLine()) != null) {
                final StringTokenizer st = new StringTokenizer(line, ";", false);
                final String name = st.nextToken().trim();
                String hex = st.nextToken().trim();
                hex = hex.replace("#", "");
                final int r = Integer.parseInt(hex.substring(0, 2), 16);
                final int g = Integer.parseInt(hex.substring(2, 4), 16);
                final int b = Integer.parseInt(hex.substring(4, 6), 16);
                final String rgbString = (r + "," + g + "," + b);
                LOG.debug("public static final MTColor " + name.toUpperCase() + " = new MTColor(" + rgbString + ");");
                LOG.debug("{colors.put(\"" + name.toUpperCase() + "\", " + name.toUpperCase() + ");}");
            }
        } catch (final FileNotFoundException e) {
            e.printStackTrace();
        } catch (final IOException e) {
            e.printStackTrace();
        }
    }

    private static int cnt = 0;

    public static MTColor getNext() {
        final String[] colorNames = colors.keySet().toArray(new String[colors.size()]);
        Arrays.sort(colorNames);
        if (cnt >= colorNames.length) {
            cnt = 0;
        }
        return colors.get(colorNames[cnt++]);
    }

    public static MTColor get(String name) {
        return colors.get(name);
    }
}
